import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../views/login.vue'

Vue.use(VueRouter)

//======== 解决菜单重复点击报红=====
//push
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
//replace
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (to) {
  return VueRouterReplace.call(this, to).catch(err => err)
}
//==========

const routes = [
  // 自动重定向到login
  {path:"/",redirect:'/login'},
  {path:"/login",name:"login",component: login},
  {
    path:"/home",
    name:"home",
    component: ()=>import("../views/home.vue"),
    //自动重定向到welcome页面
    redirect:'/welcome',
    children:[
      {
      path:"/welcome",
      component:()=>import('../views/welcome.vue')
      },
      {
        path:"/PmsCategory",
        component:()=>import('../views/product/PmsCategory.vue')
      },
      {
        path:"/PmsBrand",
        component:()=>import('../views/product/PmsBrand.vue')
      },
      {
        path:"/PmsAttrGroup",
        component:()=>import('../views/product/PmsAttrGroup.vue')
      },
      {
        path:"/PmsAttr",
        component:()=>import('../views/product/PmsAttr.vue')
      },

    ]
  }

]



const router = new VueRouter({
  routes
})


export default router
